package com.rmfyzxfw.caseprocess.manager;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Sets;
import com.rmfyzxfw.caseprocess.enums.CaseTypeEnum;
import com.rmfyzxfw.caseprocess.mapper.DmAjzhMapper;
import com.rmfyzxfw.caseprocess.model.po.DmAjzh;
import com.rmfyzxfw.caseprocess.model.po.ZXCaseInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @Author: GYW  742926306@qq.com
 * @Date: 2024/9/13 17:31
 */
@Component
@RequiredArgsConstructor
public class CaseManager {
    private final DmAjzhMapper dmAjzhMapper;

    /**
     * 设置案件类型
     * @param zxCaseInfo
     */
    public void setCaseType(ZXCaseInfo zxCaseInfo) {
        // TODO 暂时先做两个 1.根据实际案件类型给zxCaseInfo.caseType赋值 同一个案件可能属于多个案件类型？
        DmAjzh dmAjzh = dmAjzhMapper.selectOne(Wrappers.<DmAjzh>lambdaQuery().eq(DmAjzh::getFydm, zxCaseInfo.getFydm()).eq(DmAjzh::getAjzh, zxCaseInfo.getAjzh()));
        if("执保".equals(dmAjzh.getDsjajzh())){
            zxCaseInfo.setCaseType(CaseTypeEnum.ZB.getType());
            return;
        }

        if(Sets.newHashSet("执异","执监", "执协", "执复").contains(dmAjzh.getAjzh())){
            zxCaseInfo.setCaseType(CaseTypeEnum.SC.getType());
            return;
        }
    }
}